<!DOCTYPE html>
<html>
<head>
  <meta content="text/html; charset=utf-8" http-equiv="content-type">
  <title>上传文件</title>
  <style>
  body {height: 40px;}
  .wrap-word {word-wrap:break-word; overflow:hidden;}
  .text-warning {color: #ff7518;}
  #upfile {margin:2px;width:95%;height:22px;line-height:18px;border:1px solid green;}
  </style>
  <script src="jquery.min.js"></script>
</head>
<body>
<div class="wrap-word">
  <form enctype="multipart/form-data" accept-charset="UTF-8">
    <input type="file" name="upfile" id="upfile">
    <hr>
    <input type="button" id="uploadfile" value="上传">
    <span class="text-warning"></span>
  </form>
</div>
<script>
var do_upload,_validateFile;_validateFile=function(){var a,b,c;return 0===$(":file")[0].files.lenght?!1:(a=$(":file")[0].files[0],b=a.size/1e3,c=a.type.slice(0,5)||a.name.split(".").slice(-1)[0],b>1e4?($(".text-warning").html("文件太大了"),!1):!0)},do_upload=function(){var a;return $("#upfile").val()?(a=new FormData($("form")[0]),$.ajax({url:"/fileman/upload",type:"POST",xhr:function(){var a;return a=$.ajaxSettings.xhr()},beforeSend:function(){return $("#upfile").attr("disabled","disabled")},success:function(a){$("#upfile").removeAttr("disabled"),console.log(a),a.url?(window.parent.document.getElementById("_FILEUP_").value="/res/uploads/"+a.url[0],$(".text-warning").html("")):$(".text-warning").html(a.errmsg)},error:function(a){return $("#upfile").removeAttr("disabled"),$(".text-warning").html(a.statusText)},data:a,cache:!1,contentType:!1,processData:!1})):!1},$(function(){$("#uploadfile").click(do_upload),$(":file").change(function(){return _validateFile()?$("#upfile").removeAttr("disabled"):!1})});
</script>
</body>
</html>